﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Jhong.FunMVC.Test.Infrastructure
{
    public static class DateTimeHelper
    {
        public static long ToUnixTime(this DateTime dt)
        {
            return dt.Ticks / 10000 - 62135596800000;
        }

        public static DateTime ToDateTime(this long ticks)
        {
            return new DateTime((ticks + 62135596800000) * 10000);
        }

        public static string Month2(this long ticks)
        {
            var month = ticks.ToDateTime().Month;
            switch (month)
            {
                case 1: return "January";
                case 2: return "February";
                case 3: return "March";
                case 4: return "April";
                case 5: return "May";
                case 6: return "June";
                case 7: return "July";
                case 8: return "August";
                case 9: return "September";
                case 10: return "October";
                case 11: return "November";
                case 12: return "December";
                default: return string.Empty;
            }
        }
    }
}